home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_08
/
9n08098a
< prev
next >
Wrap
Text File
|
1991-06-15
|
382b
|
19 lines
int wordcount(char *str)
{
int count = 0;
char *s;
s=str;
while(*s && *s==' ')
s++; //Skip leading spaces
while(s)
{
s=strchr(s,' '); //Find the first word break
while(*s && *s==' ')
s++; //Allow for multiple spaces
count++; //Increment count - Note it starts as 0 not 1
}
return(count);
}